<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>view/workArea/others/teamFse</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../css/global.css">
		<link rel="stylesheet" href="../../../css/style.css">
		<link href="../../../css/task.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">Team下FSE查询</h1>
		</header>
		
		<div class="mui-content">
			<div class="details_con" style="margin: 0;">
				<div class="item_box" id="itemBox">
				</div>
				<div style="height: 50px;"></div>
			</div>
		</div>
		

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<!-- 基础js end -->

		<script type="text/javascript" charset="utf-8">
			(function($, doc) {
				$.init();
				$.plusReady(function() {
					selectList();
				});
			}(mui, document));

			function selectList() {
				var teamleaderId = app.getUser().enginnerId;
				ajaxPost(BASE_URL + "cc/engineerManage/selectTeamFseLocal", {
					"teamleaderId": teamleaderId
				}, function(data) {
					// console.log(JSON.stringify(data))
					if (data.code == 200) {//查询成功
						var arr = data.data;
						if (arr.length == 0) {
							noData();
							return false;
						}
						var str = "";
						for (var i = 0; i < arr.length; i++) {
							var message = "";
							if (arr[i].online == "0") {
								message = "离线"
							} else if (arr[i].stateDescribe) {
								message = getStateDescribeName(arr[i].stateDescribe)
							} else if (arr[i].networkState && arr[i].networkState == "NONE") {
								message = "网络异常"; //没有网络
							} else if (arr[i].state != "undefined" && arr[i].state == "0") {
								message = "位置服务不可用"; //没有网络
							} else if (!arr[i].stateDescribe && !arr[i].networkState && !arr[i].state) {
								message = "离线";
							} else {
								message = "正常";
							}
							str += '<div class="item" onclick="jumpToWorkPlan(' + arr[i].fseId + ')">';
							str += '<div class="bar">';
							str += '<span class="number">'+ arr[i].fseName +'<img src="../../../images/icon_204.png" /></span>';
							str += '</div>';
							str += '<div class="type">';
							str += '<p><img src="../../../images/icon_229.png"/>最近一次位置：<span>'+ emptyStr(arr[i].address) +'</span></p>';
							str += '<p>定位时间：<span>'+ emptyStr(arr[i].receiveDate) +'</span><img src="../../../images/icon_202.png"/></p>';
							str += '<p>状态信息：<span>'+ message +'</span><img src="../../../images/icon_205.png"/></p>';
							str += '</div>';
							str += '</div>';
						}
						h("#itemBox").html(str);
					} else {//查询失败
						noData();
						app.toast(data.msg);
					}
				}, function(errorMsg) {
					noData();
					app.toast("数据获取失败，请检查网络连接");
				});
			}
			
			// 高德定位错误码转名称
			function getStateDescribeName(stateDescribe) {
				if (stateDescribe == 2) {
					return "定位错误"
				} else if (stateDescribe == 3) {
					return "逆地理错误"
				} else if (stateDescribe == 4) {
					return "访问超时"
				} else if (stateDescribe == 5) {
					return "单次定位取消"
				} else if (stateDescribe == 6) {
					return "找不到主机"
				} else if (stateDescribe == 7) {
					return "URL异常"
				} else if (stateDescribe == 8) {
					return "连接异常"
				} else if (stateDescribe == 9) {
					return "服务器连接失败"
				} else if (stateDescribe == 10) {
					return "地理围栏错误"
				} else {
					return "定位异常"
				}
			}
			
			function noData() {
				html = '<div class="nodata">—— 暂无数据 ——</div>';
				h("#itemBox").html(html);
			}
			
			// 跳转fse计划安排
			function jumpToWorkPlan(enginnerId){
				app.jumpTo("/view/workArea/plan/workPlan.html", "view/workArea/plan/workPlan", {
					"enginnerId": enginnerId
				});
			}
		</script>
		<!-- js代码 end -->

	</body>

</html>
